import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { EntityHelper } from '../../utils/entity-helper';
import { Role } from '../../role/entities/role.entity';
import { Menu } from '../../menu/entities/menu.entity';

@Entity('role_menu')
export class RoleMenu extends EntityHelper {
	@PrimaryGeneratedColumn()
	id: number;

	@Column({ name: 'role_id' })
	roleId: number;

	@Column({ name: 'menu_id' })
	menuId: number;

	@ManyToOne((type) => Menu, (menu) => menu.id)
	@JoinColumn({ name: 'menu_id' })
	menu: Menu;

	@ManyToOne((type) => Role, (role) => role.id)
	@JoinColumn({ name: 'role_id' })
	role: Role;
}
